
-- --------------------------------------------------
-- Entity Designer DDL Script for SQL Server 2005, 2008, and Azure
-- --------------------------------------------------
-- Date Created: 02/15/2013 10:57:16
-- Generated from EDMX file: F:\work\sampleand\dotnetPart\LogicAndDB\DB.edmx
-- --------------------------------------------------

SET QUOTED_IDENTIFIER OFF;
GO
IF SCHEMA_ID(N'dbo') IS NULL EXECUTE(N'CREATE SCHEMA [dbo]');
GO

-- --------------------------------------------------
-- Dropping existing FOREIGN KEY constraints
-- --------------------------------------------------

IF OBJECT_ID(N'[dbo].[FK_UserPayRoll]', 'F') IS NOT NULL
    ALTER TABLE [dbo].[PaymentList] DROP CONSTRAINT [FK_UserPayRoll];
GO

-- --------------------------------------------------
-- Dropping existing tables
-- --------------------------------------------------

IF OBJECT_ID(N'[dbo].[UserList]', 'U') IS NOT NULL
    DROP TABLE [dbo].[UserList];
GO
IF OBJECT_ID(N'[dbo].[NewsList]', 'U') IS NOT NULL
    DROP TABLE [dbo].[NewsList];
GO
IF OBJECT_ID(N'[dbo].[PaymentList]', 'U') IS NOT NULL
    DROP TABLE [dbo].[PaymentList];
GO

-- --------------------------------------------------
-- Creating all tables
-- --------------------------------------------------

-- Creating table 'UserList'
CREATE TABLE [dbo].[UserList] (
    [ID] int IDENTITY(1,1) NOT NULL,
    [Name] nvarchar(max)  NOT NULL,
    [Mail] nvarchar(max)  NOT NULL,
    [LastLogin] datetime  NOT NULL,
    [Password] nvarchar(max)  NOT NULL,
    [Activated] bit  NOT NULL,
    [ActivationKey] nvarchar(max)  NOT NULL
);
GO

-- Creating table 'NewsList'
CREATE TABLE [dbo].[NewsList] (
    [NewsId] int IDENTITY(1,1) NOT NULL,
    [Content] nvarchar(max)  NOT NULL,
    [PublishDate] datetime  NOT NULL,
    [Title] nvarchar(max)  NOT NULL
);
GO

-- Creating table 'PaymentList'
CREATE TABLE [dbo].[PaymentList] (
    [ID] int IDENTITY(1,1) NOT NULL,
    [Amount] int  NOT NULL,
    [PayTime] datetime  NOT NULL,
    [User_ID] int  NULL
);
GO

-- --------------------------------------------------
-- Creating all PRIMARY KEY constraints
-- --------------------------------------------------

-- Creating primary key on [ID] in table 'UserList'
ALTER TABLE [dbo].[UserList]
ADD CONSTRAINT [PK_UserList]
    PRIMARY KEY CLUSTERED ([ID] ASC);
GO

-- Creating primary key on [NewsId] in table 'NewsList'
ALTER TABLE [dbo].[NewsList]
ADD CONSTRAINT [PK_NewsList]
    PRIMARY KEY CLUSTERED ([NewsId] ASC);
GO

-- Creating primary key on [ID] in table 'PaymentList'
ALTER TABLE [dbo].[PaymentList]
ADD CONSTRAINT [PK_PaymentList]
    PRIMARY KEY CLUSTERED ([ID] ASC);
GO

-- --------------------------------------------------
-- Creating all FOREIGN KEY constraints
-- --------------------------------------------------

-- Creating foreign key on [User_ID] in table 'PaymentList'
ALTER TABLE [dbo].[PaymentList]
ADD CONSTRAINT [FK_UserPayRoll]
    FOREIGN KEY ([User_ID])
    REFERENCES [dbo].[UserList]
        ([ID])
    ON DELETE NO ACTION ON UPDATE NO ACTION;

-- Creating non-clustered index for FOREIGN KEY 'FK_UserPayRoll'
CREATE INDEX [IX_FK_UserPayRoll]
ON [dbo].[PaymentList]
    ([User_ID]);
GO

-- --------------------------------------------------
-- Script has ended
-- --------------------------------------------------